<% attachments ||= [] -%>

<% attachments.each_with_index do |a, i| -%>
  <% next if a.new_record? -%>
  <dl>
  <% div_for a do -%>
    <%= hidden_field "existing_attachment_#{i}", 'id', :value => a.id %>
    <dt>
      <%= link_to_function( image_tag( 'tango/22x22/emblems/emblem-unreadable.png',
                            :alt => 'remove this attachment',
                            :class => 'remove_img') ) do |page|
        page.remove dom_id( a )
      end %>
    </dt>
    <dd><div class="attachments_and_changes">
      <%= render :partial => 'shared/attachment', :locals => { :attachment => a } %>
    </div></dd>
  <% end -%>
  </dl>
<% end -%>

<%= render :partial => 'shared/attach' %>
